package com.misboot.document.service.impl;

import cn.hutool.core.date.DateTime;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.misboot.document.mapper.DfsFileMapper;
import com.misboot.document.model.DfsFile;
import com.misboot.document.service.DfsFileService;
import com.misboot.document.utils.PageUtil.PageParam;
import com.misboot.document.utils.PageUtil.PageSet;
import com.misboot.document.utils.PageUtil.PageUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service("dfsFileServiceImpl")
public class DfsFileServiceImpl extends DocumentBaseServiceImpl<DfsFile, String> implements DfsFileService {

	@Autowired
	private DfsFileMapper dfsFileMapper;

    @Override
    public PageSet<DfsFile> getPageSet(PageParam pageParam, String filterSort, String fileName,String puuid) {
        PageHelper.startPage(pageParam.getPageNo(), pageParam.getPageSize());
        List<DfsFile> list = dfsFileMapper.getPageSet(filterSort,fileName,puuid);
        PageInfo<DfsFile> pageInfo = new PageInfo<>(list);
        return PageUtils.getPageSet(pageInfo);
    }

	@Override
	public String getDataCountByPuuid(String puuid){
		return dfsFileMapper.getDataCountByPuuid(puuid);
	}

	@Override
	public PageSet<DfsFile> getPageSetUuids(PageParam pageParam, String filterSort , String uuids) {
		PageHelper.startPage(pageParam.getPageNo(), pageParam.getPageSize());
		List<DfsFile> list = dfsFileMapper.getPageSetUuids(filterSort, uuids);
		PageInfo<DfsFile> pageInfo = new PageInfo<>(list);
		return PageUtils.getPageSet(pageInfo);
	}

	@Override
	public List<DfsFile> getListByPuuid (String filterSort){
		return dfsFileMapper.getDfsFileList(filterSort);
	}

	@Override
	public DfsFile queryObject(String uuid){
		return dfsFileMapper.queryObject(uuid);
	}

	@Override
	public List<DfsFile> queryList(Map<String, Object> map){
		return dfsFileMapper.queryList(map);
	}

	@Override
	public int queryTotal(Map<String, Object> map){
		return dfsFileMapper.queryTotal(map);
	}

	@Override
	public int executeSave(DfsFile dfsFile){
		return dfsFileMapper.executeSave(dfsFile);
	}

	@Override
	public int executeUpdate(DfsFile dfsFile){
		return dfsFileMapper.executeUpdate(dfsFile);
	}

	@Override
	public int executeDelete(String uuid){
		return dfsFileMapper.executeDelete(uuid);
	}

	@Override
	public int executeDeleteBatch(String[] uuids){
		return dfsFileMapper.executeDeleteBatch(uuids);
	}

	@Override
	public int executeDeleteByName(String fileName){
		return dfsFileMapper.executeDeleteByName(fileName);
	}

	@Override
	public List<DfsFile> getMaxVersionByFileName(String originalFilename) {
		return dfsFileMapper.getMaxVersionByFileName(originalFilename);
	}

	@Override
	public List<String> getAccessorylByOaRelevanceUuid(String oaRelevanceUuid) {
		return dfsFileMapper.getAccessorylByOaRelevanceUuid(oaRelevanceUuid);
	}

	@Override
	public PageSet<DfsFile> getOaPageSet(PageParam pageParam, String filterSort ,  List <String> uuids) {
		PageHelper.startPage(pageParam.getPageNo(), pageParam.getPageSize());
		List<DfsFile> list = dfsFileMapper.getOaPageSet(filterSort, uuids);
		PageInfo<DfsFile> pageInfo = new PageInfo<>(list);
		return PageUtils.getPageSet(pageInfo);
	}

	@Override
	public String getFileNameByUuid(String uuid){
		return dfsFileMapper.getFileNameByUuid(uuid);
	}

	@Override
	public List<DfsFile> getDfsFileByPuuids(String[] puuids) {
		return dfsFileMapper.getDfsFileByPuuids(puuids);
	}

	@Override
	public int deleteDfsFiles(String[] puuid) {
		return dfsFileMapper.deleteDfsFiles(puuid);
	}

    @Override
    public String selectCopyFileUrlByBusinessUuid(String businessUuid) {
        return dfsFileMapper.selectCopyFileUrlByBusinessUuid(businessUuid);
    }

    @Override
    public Integer updateCopyFileUrlByBusinessUuid(String businessUuid, String mainBody, String modifier, String modifierId, DateTime modifyTime) {
        return dfsFileMapper.updateCopyFileUrlByBusinessUuid(businessUuid, mainBody, modifier, modifierId, modifyTime);
    }
}
